<div class="headertitle">
    <label><h2>Buat Pesan</h2></label>
</div>
<?php include_once 'Pecahan/sessionLontong.php'; ?>
<?php
if (isset($_GET['name_viewed'])!= NULL) {
    $name_viewed = $_GET['name_viewed'];
}
else if (isset($_SESSION['user_name'])!= NULL) {
    $name_viewed = $_SESSION['user_name'];
}
if (isset($_SESSION['user_name'])!= NULL) {
    $name_logon = $_SESSION['user_name'];
    $temp = new login();
    $role = $temp->getRole($name_logon );
}
else {
    $name_logon = NULL;
    $role = NULL;
}
?>
<?php
include_once 'controller/message.php';
$message = new message();
if  (isset($_GET['replyMsgID']) != NULL) {
    $msg = $message->showMsgByMsgID($_GET['replyMsgID']);
    $array['subject'] = "Re: ".$msg['msg_subject'];
    $array['to'] = $msg['user_name'];
    $array['from'] = $name_logon;
    $array['body'] = $msg['user_name'] . " wrote : " . $msg['msg_body'] . " on " . $msg['post_date']. " " .$msg['post_time'] . "\n-----------------------\n\n";
    $replyOfMsgID = $_GET['replyMsgID'];
}else {
    $replyOfMsgID = 0;
}
?>
<?php $judul = 'Create Message'; ?>
<?php  include_once 'Pecahan/header.php'; ?>

<div id ="content" class="isipage">
    <div class="isipagestandar">
        <form action="<?php echo 'messagesent.php?replyOfMsgID='.$replyOfMsgID; ?>" method="post">
            <div>
                <label id="titlebold">Create New Message</label>
            </div>
            <div class="space">

            </div>
            <div>
                <label class="labelinput">To: </label>
                <input class="input" type="text" name="touser" id="touser"
                <?php
                if(isset ($_GET['to'])) {
                    echo 'value="'.$_GET['to'].'"';
                }
                else if  (isset($_GET['replyMsgID']) != NULL) {
                    echo 'value="'.$array['to'].'"';
                }
                       ?> />
            </div>
            <div class="space">

            </div>
            <div>
                <label class="labelinput">Subject: </label>
                <input class="input" type="text" name="subject" id="subject"
                <?php
                if  (isset($_GET['replyMsgID']) != NULL) {
                    echo 'value="'.$array['subject'].'"';
                }
                       ?> />
            </div>
            <div class="space">

            </div>
            <div>
                <label class="labelinput">Body: </label>
                <textarea class="input" name="bodymessage" id="bodymessage" cols="230" rows="200"><?php
                    if  (isset($_GET['replyMsgID']) != NULL) {
                        echo $array['body'];
                    }
                    ?></textarea>
            </div>

            <div class="space">

            </div>
            <div>
                <input id="sendmessage" name="sendmessageButton" type="submit" value="Send" />
            </div>
        </form>
        <div class="space">

        </div>
    </div>
</div>
<?php include_once 'Chat/chat.php';?>
<?php include_once 'Pecahan/footer.php'; ?>
